// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.iso;

import fmod.fmod.Audio;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import org.joml.Vector2f;
import zombie.Lua.LuaEventManager;
import zombie.Lua.LuaManager;
import zombie.ai.State;
import zombie.ai.astar.Mover;
import zombie.ai.states.AttackState;
import zombie.ai.states.ClimbOverFenceState;
import zombie.ai.states.ClimbThroughWindowState;
import zombie.ai.states.CollideWithWallState;
import zombie.ai.states.CrawlingZombieTurnState;
import zombie.ai.states.PathFindState;
import zombie.ai.states.StaggerBackState;
import zombie.ai.states.WalkTowardState;
import zombie.ai.states.ZombieFallDownState;
import zombie.ai.states.ZombieIdleState;
import zombie.audio.BaseSoundEmitter;
import zombie.characters.IsoGameCharacter;
import zombie.characters.IsoPlayer;
import zombie.characters.IsoSurvivor;
import zombie.characters.IsoZombie;
import zombie.characters.BodyDamage.BodyPart;
import zombie.characters.BodyDamage.BodyPartType;
import zombie.characters.skills.PerkFactory;
import zombie.core.Core;
import zombie.core.Rand;
import zombie.core.skinnedmodel.model.Model;
import zombie.core.textures.ColorInfo;
import zombie.debug.DebugLog;
import zombie.debug.DebugOptions;
import zombie.debug.LineDrawer;
import zombie.inventory.types.HandWeapon;
import zombie.inventory.types.WeaponType;
import zombie.iso.SpriteDetails.IsoFlagType;
import zombie.iso.SpriteDetails.IsoObjectType;
import zombie.iso.areas.IsoBuilding;
import zombie.iso.areas.IsoRoom;
import zombie.iso.areas.isoregion.regions.IWorldRegion;
import zombie.iso.objects.IsoMolotovCocktail;
import zombie.iso.objects.IsoThumpable;
import zombie.iso.objects.IsoTree;
import zombie.iso.objects.IsoZombieGiblets;
import zombie.iso.objects.RenderEffectType;
import zombie.iso.objects.interfaces.Thumpable;
import zombie.iso.sprite.IsoSprite;
import zombie.iso.sprite.IsoSpriteInstance;
import zombie.iso.sprite.IsoSpriteManager;
import zombie.network.GameClient;
import zombie.network.GameServer;
import zombie.network.ServerMap;
import zombie.network.ServerOptions;
import zombie.popman.ZombiePopulationManager;
import zombie.util.StringUtils;
import zombie.util.Type;
import zombie.vehicles.BaseVehicle;
import zombie.vehicles.PathFindBehavior2;
import zombie.vehicles.PolygonalMap2;

public class IsoMovingObject extends IsoObject implements Mover {
    public static IsoMovingObject.TreeSoundManager treeSoundMgr = new IsoMovingObject.TreeSoundManager();
    public static final int MAX_ZOMBIES_EATING = 3;
    private static int IDCount = 0;
    private static final Vector2 tempo = new Vector2();
    public boolean noDamage = false;
    public IsoGridSquare last = null;
    public float lx;
    public float ly;
    public float lz;
    public float nx;
    public float ny;
    public float x;
    public float y;
    public float z;
    public IsoSpriteInstance def = null;
    protected IsoGridSquare current = null;
    protected Vector2 hitDir = new Vector2();
    protected int ID = 0;
    protected IsoGridSquare movingSq = null;
    protected boolean solid = true;
    protected float width = 0.24F;
    protected boolean shootable = true;
    protected boolean Collidable = true;
    protected float scriptnx = 0.0F;
    protected float scriptny = 0.0F;
    protected String ScriptModule = "none";
    protected Vector2 movementLastFrame = new Vector2();
    protected float weight = 1.0F;
    boolean bOnFloor = false;
    private boolean closeKilled = false;
    private String collideType = null;
    private float lastCollideTime = 0.0F;
    private int TimeSinceZombieAttack = 1000000;
    private boolean collidedE = false;
    private boolean collidedN = false;
    private IsoObject CollidedObject = null;
    private boolean collidedS = false;
    private boolean collidedThisFrame = false;
    private boolean collidedW = false;
    private boolean CollidedWithDoor = false;
    private boolean collidedWithVehicle = false;
    private boolean destroyed = false;
    private boolean firstUpdate = true;
    private float impulsex = 0.0F;
    private float impulsey = 0.0F;
    private float limpulsex = 0.0F;
    private float limpulsey = 0.0F;
    private float hitForce = 0.0F;
    private float hitFromAngle;
    private int PathFindIndex = -1;
    private float StateEventDelayTimer = 0.0F;
    private Thumpable thumpTarget = null;
    private boolean bAltCollide = false;
    private IsoZombie lastTargettedBy = null;
    private float feelersize = 0.5F;
    public final boolean[] bOutline = new boolean[4];
    public final ColorInfo[] outlineColor = new ColorInfo[4];
    private final ArrayList<IsoZombie> eatingZombies = new ArrayList();
    private boolean zombiesDontAttack = false;

    public IsoMovingObject(IsoCell cell) {
        this.sprite = IsoSprite.CreateSprite(IsoSpriteManager.instance);
        if (cell != null) {
            this.ID = IDCount++;
            if (this.getCell().isSafeToAdd()) {
                this.getCell().getObjectList().add(this);
            } else {
                this.getCell().getAddList().add(this);
            }
        }
    }

    public IsoMovingObject(IsoCell cell, boolean bObjectListAdd) {
        this.ID = IDCount++;
        this.sprite = IsoSprite.CreateSprite(IsoSpriteManager.instance);
        if (bObjectListAdd) {
            if (this.getCell().isSafeToAdd()) {
                this.getCell().getObjectList().add(this);
            } else {
                this.getCell().getAddList().add(this);
            }
        }
    }

    public IsoMovingObject(IsoCell cell, IsoGridSquare square, IsoSprite spr, boolean bObjectListAdd) {
        this.ID = IDCount++;
        this.sprite = spr;
        if (bObjectListAdd) {
            if (this.getCell().isSafeToAdd()) {
                this.getCell().getObjectList().add(this);
            } else {
                this.getCell().getAddList().add(this);
            }
        }
    }

    public IsoMovingObject() {
        this.ID = IDCount++;
        this.getCell().getAddList().add(this);
    }

    public static int getIDCount() {
        return IDCount;
    }

    public static void setIDCount(int aIDCount) {
        IDCount = aIDCount;
    }

    public IsoBuilding getBuilding() {
        if (this.current == null) {
            return null;
        } else {
            IsoRoom isoRoom = this.current.getRoom();
            return isoRoom == null ? null : isoRoom.building;
        }
    }

    public IWorldRegion getMasterRegion() {
        return this.current != null ? this.current.getIsoWorldRegion() : null;
    }

    public float getWeight() {
        return this.weight;
    }

    public void setWeight(float _weight) {
        this.weight = _weight;
    }

    public float getWeight(float _x, float _y) {
        return this.weight;
    }

    @Override
    public void onMouseRightClick(int _lx, int _ly) {
        if (this.square.getZ() == (int)IsoPlayer.getInstance().getZ() && this.DistToProper(IsoPlayer.getInstance()) <= 2.0F) {
            IsoPlayer.getInstance().setDragObject(this);
        }
    }

    @Override
    public String getObjectName() {
        return "IsoMovingObject";
    }

    @Override
    public void onMouseRightReleased() {
    }

    public void collideWith(IsoObject obj) {
        if (this instanceof IsoGameCharacter && obj instanceof IsoGameCharacter) {
            LuaEventManager.triggerEvent("OnCharacterCollide", this, obj);
        } else {
            LuaEventManager.triggerEvent("OnObjectCollide", this, obj);
        }
    }

    public void doStairs() {
        if (this.current != null) {
            if (this.last != null) {
                if (!(this instanceof IsoPhysicsObject)) {
                    IsoGridSquare isoGridSquare0 = this.current;
                    if (isoGridSquare0.z > 0
                        && (isoGridSquare0.Has(IsoObjectType.stairsTN) || isoGridSquare0.Has(IsoObjectType.stairsTW))
                        && this.z - (float)((int)this.z) < 0.1F) {
                        IsoGridSquare isoGridSquare1 = IsoWorld.instance.CurrentCell.getGridSquare(isoGridSquare0.x, isoGridSquare0.y, isoGridSquare0.z - 1);
                        if (isoGridSquare1 != null && (isoGridSquare1.Has(IsoObjectType.stairsTN) || isoGridSquare1.Has(IsoObjectType.stairsTW))) {
                            isoGridSquare0 = isoGridSquare1;
                        }
                    }

                    if (this instanceof IsoGameCharacter && (this.last.Has(IsoObjectType.stairsTN) || this.last.Has(IsoObjectType.stairsTW))) {
                        this.z = (float)Math.round(this.z);
                    }

                    float _float = this.z;
                    if (isoGridSquare0.HasStairs()) {
                        _float = isoGridSquare0.getApparentZ(this.x - (float)isoGridSquare0.getX(), this.y - (float)isoGridSquare0.getY());
                    }

                    if (this instanceof IsoGameCharacter) {
                        State state = ((IsoGameCharacter)this).getCurrentState();
                        if (state == ClimbOverFenceState.instance() || state == ClimbThroughWindowState.instance()) {
                            if (isoGridSquare0.HasStairs() && this.z > _float) {
                                this.z = Math.max(_float, this.z - 0.075F * zombie.GameTime.getInstance().getMultiplier());
                            }

                            return;
                        }
                    }

                    if (Math.abs(_float - this.z) < 0.95F) {
                        this.z = _float;
                    }
                }
            }
        }
    }

    @Override
    public int getID() {
        return this.ID;
    }

    public void setID(int _ID) {
        this.ID = _ID;
    }

    @Override
    public int getPathFindIndex() {
        return this.PathFindIndex;
    }

    public void setPathFindIndex(int _PathFindIndex) {
        this.PathFindIndex = _PathFindIndex;
    }

    public float getScreenX() {
        return IsoUtils.XToScreen(this.x, this.y, this.z, 0);
    }

    public float getScreenY() {
        return IsoUtils.YToScreen(this.x, this.y, this.z, 0);
    }

    public Thumpable getThumpTarget() {
        return this.thumpTarget;
    }

    public void setThumpTarget(Thumpable _thumpTarget) {
        this.thumpTarget = _thumpTarget;
    }

    public Vector2 getVectorFromDirection(Vector2 moveForwardVec) {
        return getVectorFromDirection(moveForwardVec, this.dir);
    }

    public static Vector2 getVectorFromDirection(Vector2 moveForwardVec, IsoDirections dir) {
        if (moveForwardVec == null) {
            DebugLog.General.warn("Supplied vector2 is null. Cannot be processed. Using fail-safe fallback.");
            moveForwardVec = new Vector2();
        }

        moveForwardVec.x = 0.0F;
        moveForwardVec.y = 0.0F;
        switch (dir) {
            case S:
                moveForwardVec.x = 0.0F;
                moveForwardVec.y = 1.0F;
                break;
            case N:
                moveForwardVec.x = 0.0F;
                moveForwardVec.y = -1.0F;
                break;
            case E:
                moveForwardVec.x = 1.0F;
                moveForwardVec.y = 0.0F;
                break;
            case W:
                moveForwardVec.x = -1.0F;
                moveForwardVec.y = 0.0F;
                break;
            case NW:
                moveForwardVec.x = -1.0F;
                moveForwardVec.y = -1.0F;
                break;
            case NE:
                moveForwardVec.x = 1.0F;
                moveForwardVec.y = -1.0F;
                break;
            case SW:
                moveForwardVec.x = -1.0F;
                moveForwardVec.y = 1.0F;
                break;
            case SE:
                moveForwardVec.x = 1.0F;
                moveForwardVec.y = 1.0F;
        }

        moveForwardVec.normalize();
        return moveForwardVec;
    }

    public Vector3 getPosition(Vector3 out) {
        out.set(this.getX(), this.getY(), this.getZ());
        return out;
    }

    @Override
    public float getX() {
        return this.x;
    }

    public void setX(float _x) {
        this.x = _x;
        this.nx = _x;
        this.scriptnx = _x;
    }

    @Override
    public float getY() {
        return this.y;
    }

    public void setY(float _y) {
        this.y = _y;
        this.ny = _y;
        this.scriptny = _y;
    }

    @Override
    public float getZ() {
        return this.z;
    }

    public void setZ(float _z) {
        this.z = _z;
        this.lz = _z;
    }

    @Override
    public IsoGridSquare getSquare() {
        return this.current != null ? this.current : this.square;
    }

    public IsoBuilding getCurrentBuilding() {
        if (this.current == null) {
            return null;
        } else {
            return this.current.getRoom() == null ? null : this.current.getRoom().building;
        }
    }

    public float Hit(HandWeapon weapon, IsoGameCharacter wielder, float damageSplit, boolean bIgnoreDamage, float modDelta) {
        return 0.0F;
    }

    public void Move(Vector2 dir) {
        this.nx = this.nx + dir.x * zombie.GameTime.instance.getMultiplier();
        this.ny = this.ny + dir.y * zombie.GameTime.instance.getMultiplier();
        if (this instanceof IsoPlayer) {
            this.current = IsoWorld.instance.CurrentCell.getGridSquare((double)this.x, (double)this.y, (double)((int)this.z));
        }
    }

    public void MoveUnmodded(Vector2 dir) {
        this.nx = this.nx + dir.x;
        this.ny = this.ny + dir.y;
        if (this instanceof IsoPlayer) {
            this.current = IsoWorld.instance.CurrentCell.getGridSquare((double)this.x, (double)this.y, (double)((int)this.z));
        }
    }

    @Override
    public boolean isCharacter() {
        return this instanceof IsoGameCharacter;
    }

    public float DistTo(int _x, int _y) {
        return IsoUtils.DistanceManhatten((float)_x, (float)_y, this.x, this.y);
    }

    public float DistTo(IsoMovingObject other) {
        return IsoUtils.DistanceManhatten(this.x, this.y, other.x, other.y);
    }

    public float DistToProper(IsoObject other) {
        return IsoUtils.DistanceTo(this.x, this.y, other.getX(), other.getY());
    }

    public float DistToSquared(IsoMovingObject other) {
        return IsoUtils.DistanceToSquared(this.x, this.y, other.x, other.y);
    }

    public float DistToSquared(float _x, float _y) {
        return IsoUtils.DistanceToSquared(_x, _y, this.x, this.y);
    }

    @Override
    public void load(ByteBuffer input, int WorldVersion, boolean IS_DEBUG_SAVE) throws IOException {
        float float0 = input.getFloat();
        float float1 = input.getFloat();
        this.x = this.lx = this.nx = this.scriptnx = input.getFloat() + (float)(IsoWorld.saveoffsetx * 300);
        this.y = this.ly = this.ny = this.scriptny = input.getFloat() + (float)(IsoWorld.saveoffsety * 300);
        this.z = this.lz = input.getFloat();
        this.dir = IsoDirections.fromIndex(input.getInt());
        if (input.get() != 0) {
            if (this.table == null) {
                this.table = LuaManager.platform.newTable();
            }

            this.table.load(input, WorldVersion);
        }
    }

    @Override
    public void save(ByteBuffer output, boolean IS_DEBUG_SAVE) throws IOException {
        output.put((byte)(this.Serialize() ? 1 : 0));
        output.put(IsoObject.factoryGetClassID(this.getObjectName()));
        output.putFloat(this.offsetX);
        output.putFloat(this.offsetY);
        output.putFloat(this.x);
        output.putFloat(this.y);
        output.putFloat(this.z);
        output.putInt(this.dir.index());
        if (this.table != null && !this.table.isEmpty()) {
            output.put((byte)1);
            this.table.save(output);
        } else {
            output.put((byte)0);
        }
    }

    @Override
    public void removeFromWorld() {
        IsoCell isoCell = this.getCell();
        if (isoCell.isSafeToAdd()) {
            isoCell.getObjectList().remove(this);
            isoCell.getRemoveList().remove(this);
        } else {
            isoCell.getRemoveList().add(this);
        }

        isoCell.getAddList().remove(this);
        zombie.MovingObjectUpdateScheduler.instance.removeObject(this);
        super.removeFromWorld();
    }

    @Override
    public void removeFromSquare() {
        if (this.current != null) {
            this.current.getMovingObjects().remove(this);
        }

        if (this.last != null) {
            this.last.getMovingObjects().remove(this);
        }

        if (this.movingSq != null) {
            this.movingSq.getMovingObjects().remove(this);
        }

        this.current = this.last = this.movingSq = null;
        if (this.square != null) {
            this.square.getStaticMovingObjects().remove(this);
        }

        super.removeFromSquare();
    }

    public IsoGridSquare getFuturWalkedSquare() {
        if (this.current != null) {
            IsoGridSquare isoGridSquare = this.getFeelerTile(this.feelersize);
            if (isoGridSquare != null && isoGridSquare != this.current) {
                return isoGridSquare;
            }
        }

        return null;
    }

    public float getGlobalMovementMod() {
        return this.getGlobalMovementMod(true);
    }

    public float getGlobalMovementMod(boolean bDoNoises) {
        if (this.current != null && this.z - (float)((int)this.z) < 0.5F) {
            if (this.current.Has(IsoObjectType.tree) || this.current.getProperties() != null && this.current.getProperties().Is("Bush")) {
                if (bDoNoises) {
                    this.doTreeNoises();
                }

                for (int int0 = 1; int0 < this.current.getObjects().size(); int0++) {
                    IsoObject isoObject0 = this.current.getObjects().get(int0);
                    if (isoObject0 instanceof IsoTree) {
                        isoObject0.setRenderEffect(RenderEffectType.Vegetation_Rustle);
                    } else if (isoObject0.getProperties() != null && isoObject0.getProperties().Is("Bush")) {
                        isoObject0.setRenderEffect(RenderEffectType.Vegetation_Rustle);
                    }
                }
            }

            IsoGridSquare isoGridSquare = this.getFeelerTile(this.feelersize);
            if (isoGridSquare != null
                && isoGridSquare != this.current
                && (isoGridSquare.Has(IsoObjectType.tree) || isoGridSquare.getProperties() != null && isoGridSquare.getProperties().Is("Bush"))) {
                if (bDoNoises) {
                    this.doTreeNoises();
                }

                for (int int1 = 1; int1 < isoGridSquare.getObjects().size(); int1++) {
                    IsoObject isoObject1 = isoGridSquare.getObjects().get(int1);
                    if (isoObject1 instanceof IsoTree) {
                        isoObject1.setRenderEffect(RenderEffectType.Vegetation_Rustle);
                    } else if (isoObject1.getSprite() != null && isoObject1.getProperties().Is("Bush")) {
                        isoObject1.setRenderEffect(RenderEffectType.Vegetation_Rustle);
                    }
                }
            }
        }

        return this.current != null && this.current.HasStairs() ? 0.75F : 1.0F;
    }

    private void doTreeNoises() {
        if (!GameServer.bServer) {
            if (!(this instanceof IsoPhysicsObject)) {
                if (this.current != null) {
                    if (Rand.Next(Rand.AdjustForFramerate(50)) == 0) {
                        treeSoundMgr.addSquare(this.current);
                    }
                }
            }
        }
    }

    public void postupdate() {
        IsoGameCharacter isoGameCharacter = Type.tryCastTo(this, IsoGameCharacter.class);
        IsoPlayer isoPlayer = Type.tryCastTo(this, IsoPlayer.class);
        IsoZombie isoZombie = Type.tryCastTo(this, IsoZombie.class);
        this.slideAwayFromWalls();
        if (isoZombie != null && GameServer.bServer && !isoZombie.isCurrentState(ZombieIdleState.instance())) {
            boolean boolean0 = false;
        }

        if (isoPlayer != null && isoPlayer.isLocalPlayer()) {
            IsoPlayer.setInstance(isoPlayer);
            IsoCamera.CamCharacter = isoPlayer;
        }

        this.ensureOnTile();
        if (this.lastTargettedBy != null && this.lastTargettedBy.isDead()) {
            this.lastTargettedBy = null;
        }

        if (this.lastTargettedBy != null && this.TimeSinceZombieAttack > 120) {
            this.lastTargettedBy = null;
        }

        this.TimeSinceZombieAttack++;
        if (isoPlayer != null) {
            isoPlayer.setLastCollidedW(this.collidedW);
            isoPlayer.setLastCollidedN(this.collidedN);
        }

        if (!this.destroyed) {
            this.collidedThisFrame = false;
            this.collidedN = false;
            this.collidedS = false;
            this.collidedW = false;
            this.collidedE = false;
            this.CollidedWithDoor = false;
            this.last = this.current;
            this.CollidedObject = null;
            this.nx = this.nx + this.impulsex;
            this.ny = this.ny + this.impulsey;
            if (this.nx < 0.0F) {
                this.nx = 0.0F;
            }

            if (this.ny < 0.0F) {
                this.ny = 0.0F;
            }

            tempo.set(this.nx - this.x, this.ny - this.y);
            if (tempo.getLength() > 1.0F) {
                tempo.normalize();
                this.nx = this.x + tempo.getX();
                this.ny = this.y + tempo.getY();
            }

            this.impulsex = 0.0F;
            this.impulsey = 0.0F;
            if (isoZombie == null
                || (int)this.z != 0
                || this.getCurrentBuilding() != null
                || this.isInLoadedArea((int)this.nx, (int)this.ny)
                || !isoZombie.isCurrentState(PathFindState.instance()) && !isoZombie.isCurrentState(WalkTowardState.instance())) {
                float float0 = this.nx;
                float float1 = this.ny;
                this.collidedWithVehicle = false;
                if (isoGameCharacter != null
                    && !this.isOnFloor()
                    && isoGameCharacter.getVehicle() == null
                    && this.isCollidable()
                    && (isoPlayer == null || !isoPlayer.isNoClip())) {
                    int int0 = (int)this.x;
                    int int1 = (int)this.y;
                    int int2 = (int)this.nx;
                    int int3 = (int)this.ny;
                    int int4 = (int)this.z;
                    if (isoGameCharacter.getCurrentState() == null
                        || !isoGameCharacter.getCurrentState().isIgnoreCollide(isoGameCharacter, int0, int1, int4, int2, int3, int4)) {
                        Vector2f vector2f = PolygonalMap2.instance.resolveCollision(isoGameCharacter, this.nx, this.ny, IsoMovingObject.L_postUpdate.vector2f);
                        if (vector2f.x != this.nx || vector2f.y != this.ny) {
                            this.nx = vector2f.x;
                            this.ny = vector2f.y;
                            this.collidedWithVehicle = true;
                        }
                    }
                }

                float float2 = this.nx;
                float float3 = this.ny;
                float float4 = 0.0F;
                boolean boolean1 = false;
                if (this.Collidable) {
                    if (this.bAltCollide) {
                        this.DoCollide(2);
                    } else {
                        this.DoCollide(1);
                    }

                    if (this.collidedN || this.collidedS) {
                        this.ny = this.ly;
                        this.DoCollideNorS();
                    }

                    if (this.collidedW || this.collidedE) {
                        this.nx = this.lx;
                        this.DoCollideWorE();
                    }

                    if (this.bAltCollide) {
                        this.DoCollide(1);
                    } else {
                        this.DoCollide(2);
                    }

                    this.bAltCollide = !this.bAltCollide;
                    if (this.collidedN || this.collidedS) {
                        this.ny = this.ly;
                        this.DoCollideNorS();
                        boolean1 = true;
                    }

                    if (this.collidedW || this.collidedE) {
                        this.nx = this.lx;
                        this.DoCollideWorE();
                        boolean1 = true;
                    }

                    float4 = Math.abs(this.nx - this.lx) + Math.abs(this.ny - this.ly);
                    float float5 = this.nx;
                    float float6 = this.ny;
                    this.nx = float2;
                    this.ny = float3;
                    if (this.Collidable && boolean1) {
                        if (this.bAltCollide) {
                            this.DoCollide(2);
                        } else {
                            this.DoCollide(1);
                        }

                        if (this.collidedN || this.collidedS) {
                            this.ny = this.ly;
                            this.DoCollideNorS();
                        }

                        if (this.collidedW || this.collidedE) {
                            this.nx = this.lx;
                            this.DoCollideWorE();
                        }

                        if (this.bAltCollide) {
                            this.DoCollide(1);
                        } else {
                            this.DoCollide(2);
                        }

                        if (this.collidedN || this.collidedS) {
                            this.ny = this.ly;
                            this.DoCollideNorS();
                            boolean1 = true;
                        }

                        if (this.collidedW || this.collidedE) {
                            this.nx = this.lx;
                            this.DoCollideWorE();
                            boolean1 = true;
                        }

                        if (Math.abs(this.nx - this.lx) + Math.abs(this.ny - this.ly) < float4) {
                            this.nx = float5;
                            this.ny = float6;
                        }
                    }
                }

                if (this.collidedThisFrame) {
                    this.current = this.last;
                }

                this.checkHitWall();
                if (isoPlayer != null
                    && !isoPlayer.isCurrentState(CollideWithWallState.instance())
                    && !this.collidedN
                    && !this.collidedS
                    && !this.collidedW
                    && !this.collidedE) {
                    this.setCollideType(null);
                }

                float float7 = this.nx - this.x;
                float float8 = this.ny - this.y;
                float float9 = !(Math.abs(float7) > 0.0F) && !(Math.abs(float8) > 0.0F) ? 0.0F : this.getGlobalMovementMod();
                if (Math.abs(float7) > 0.01F || Math.abs(float8) > 0.01F) {
                    float7 *= float9;
                    float8 *= float9;
                }

                this.x += float7;
                this.y += float8;
                this.doStairs();
                this.current = this.getCell().getGridSquare((int)this.x, (int)this.y, (int)this.z);
                if (this.current == null) {
                    for (int int5 = (int)this.z; int5 >= 0; int5--) {
                        this.current = this.getCell().getGridSquare((int)this.x, (int)this.y, int5);
                        if (this.current != null) {
                            break;
                        }
                    }

                    if (this.current == null && this.last != null) {
                        this.current = this.last;
                        this.x = this.nx = this.scriptnx = (float)this.current.getX() + 0.5F;
                        this.y = this.ny = this.scriptny = (float)this.current.getY() + 0.5F;
                    }
                }

                if (this.movingSq != null) {
                    this.movingSq.getMovingObjects().remove(this);
                    this.movingSq = null;
                }

                if (this.current != null && !this.current.getMovingObjects().contains(this)) {
                    this.current.getMovingObjects().add(this);
                    this.movingSq = this.current;
                }

                this.ensureOnTile();
                this.square = this.current;
                this.scriptnx = this.nx;
                this.scriptny = this.ny;
                this.firstUpdate = false;
            } else {
                ZombiePopulationManager.instance.virtualizeZombie(isoZombie);
            }
        }
    }

    public void ensureOnTile() {
        if (this.current == null) {
            if (!(this instanceof IsoPlayer)) {
                if (this instanceof IsoSurvivor) {
                    IsoWorld.instance.CurrentCell.Remove(this);
                    IsoWorld.instance.CurrentCell.getSurvivorList().remove(this);
                }

                return;
            }

            boolean boolean0 = true;
            boolean boolean1 = false;
            if (this.last != null && (this.last.Has(IsoObjectType.stairsTN) || this.last.Has(IsoObjectType.stairsTW))) {
                this.current = this.getCell().getGridSquare((int)this.x, (int)this.y, (int)this.z + 1);
                boolean0 = false;
            }

            if (this.current == null) {
                this.current = this.getCell().getGridSquare((int)this.x, (int)this.y, (int)this.z);
                return;
            }

            if (boolean0) {
                this.x = this.nx = this.scriptnx = (float)this.current.getX() + 0.5F;
                this.y = this.ny = this.scriptny = (float)this.current.getY() + 0.5F;
            }

            this.z = (float)this.current.getZ();
        }
    }

    public void preupdate() {
        this.nx = this.x;
        this.ny = this.y;
    }

    @Override
    public void renderlast() {
        this.bOutline[IsoCamera.frameState.playerIndex] = false;
    }

    public void spotted(IsoMovingObject other, boolean bForced) {
    }

    @Override
    public void update() {
        if (this.def == null) {
            this.def = IsoSpriteInstance.get(this.sprite);
        }

        this.movementLastFrame.x = this.x - this.lx;
        this.movementLastFrame.y = this.y - this.ly;
        this.lx = this.x;
        this.ly = this.y;
        this.lz = this.z;
        this.square = this.current;
        if (this.sprite != null) {
            this.sprite.update(this.def);
        }

        this.StateEventDelayTimer = this.StateEventDelayTimer - zombie.GameTime.instance.getMultiplier();
    }

    private void Collided() {
        this.collidedThisFrame = true;
    }

    public int compareToY(IsoMovingObject other) {
        if (this.sprite == null && other.sprite == null) {
            return 0;
        } else if (this.sprite != null && other.sprite == null) {
            return -1;
        } else if (this.sprite == null) {
            return 1;
        } else {
            float float0 = IsoUtils.YToScreen(this.x, this.y, this.z, 0);
            float float1 = IsoUtils.YToScreen(other.x, other.y, other.z, 0);
            if ((double)float0 > (double)float1) {
                return 1;
            } else {
                return (double)float0 < (double)float1 ? -1 : 0;
            }
        }
    }

    public float distToNearestCamCharacter() {
        float _float = Float.MAX_VALUE;

        for (int _int = 0; _int < IsoPlayer.numPlayers; _int++) {
            IsoPlayer isoPlayer = IsoPlayer.players[_int];
            if (isoPlayer != null) {
                _float = Math.min(_float, this.DistTo(isoPlayer));
            }
        }

        return _float;
    }

    public boolean isSolidForSeparate() {
        if (this instanceof IsoZombieGiblets) {
            return false;
        } else if (this.current == null) {
            return false;
        } else {
            return !this.solid ? false : !this.isOnFloor();
        }
    }

    public boolean isPushableForSeparate() {
        return true;
    }

    public boolean isPushedByForSeparate(IsoMovingObject other) {
        return true;
    }

    public void separate() {
        if (this.isSolidForSeparate()) {
            if (this.isPushableForSeparate()) {
                IsoGameCharacter isoGameCharacter0 = Type.tryCastTo(this, IsoGameCharacter.class);
                IsoPlayer isoPlayer0 = Type.tryCastTo(this, IsoPlayer.class);
                if (this.z < 0.0F) {
                    this.z = 0.0F;
                }

                for (int int0 = 0; int0 <= 8; int0++) {
                    IsoGridSquare isoGridSquare = int0 == 8 ? this.current : this.current.nav[int0];
                    if (isoGridSquare != null
                        && !isoGridSquare.getMovingObjects().isEmpty()
                        && (isoGridSquare == this.current || !this.current.isBlockedTo(isoGridSquare))) {
                        float float0 = isoPlayer0 != null && isoPlayer0.getPrimaryHandItem() instanceof HandWeapon
                            ? ((HandWeapon)isoPlayer0.getPrimaryHandItem()).getMaxRange()
                            : 0.3F;
                        int int1 = 0;

                        for (int int2 = isoGridSquare.getMovingObjects().size(); int1 < int2; int1++) {
                            IsoMovingObject isoMovingObject1 = (IsoMovingObject)isoGridSquare.getMovingObjects().get(int1);
                            if (isoMovingObject1 != this && isoMovingObject1.isSolidForSeparate() && !(Math.abs(this.z - isoMovingObject1.z) > 0.3F)) {
                                IsoGameCharacter isoGameCharacter1 = Type.tryCastTo(isoMovingObject1, IsoGameCharacter.class);
                                IsoPlayer isoPlayer1 = Type.tryCastTo(isoMovingObject1, IsoPlayer.class);
                                float float1 = this.width + isoMovingObject1.width;
                                Vector2 vector2 = tempo;
                                vector2.x = this.nx - isoMovingObject1.nx;
                                vector2.y = this.ny - isoMovingObject1.ny;
                                float float2 = vector2.getLength();
                                if (isoGameCharacter0 == null || isoGameCharacter1 == null && !(isoMovingObject1 instanceof BaseVehicle)) {
                                    if (float2 < float1) {
                                        zombie.CollisionManager.instance.AddContact(this, isoMovingObject1);
                                    }

                                    return;
                                }

                                if (isoGameCharacter1 != null) {
                                    if (isoPlayer0 != null
                                        && isoPlayer0.getBumpedChr() != isoMovingObject1
                                        && float2 < float1 + float0
                                        && (double)isoPlayer0.getForwardDirection().angleBetween(vector2) > 2.6179938155736564
                                        && isoPlayer0.getBeenSprintingFor() >= 70.0F
                                        && WeaponType.getWeaponType(isoPlayer0) == WeaponType.spear) {
                                        isoPlayer0.reportEvent("ChargeSpearConnect");
                                        isoPlayer0.setAttackType("charge");
                                        isoPlayer0.attackStarted = true;
                                        isoPlayer0.setVariable("StartedAttackWhileSprinting", true);
                                        isoPlayer0.setBeenSprintingFor(0.0F);
                                        return;
                                    }

                                    if (!(float2 >= float1)) {
                                        boolean boolean0 = false;
                                        if (isoPlayer0 != null
                                            && isoPlayer0.getVariableFloat("WalkSpeed", 0.0F) > 0.2F
                                            && isoPlayer0.runningTime > 0.5F
                                            && isoPlayer0.getBumpedChr() != isoMovingObject1) {
                                            boolean0 = true;
                                        }

                                        if (GameClient.bClient
                                            && isoPlayer0 != null
                                            && isoGameCharacter1 instanceof IsoPlayer
                                            && !ServerOptions.getInstance().PlayerBumpPlayer.getValue()) {
                                            boolean0 = false;
                                        }

                                        if (boolean0 && !"charge".equals(isoPlayer0.getAttackType())) {
                                            boolean boolean1 = !this.isOnFloor()
                                                && (
                                                    isoGameCharacter0.getBumpedChr() != null
                                                        || (System.currentTimeMillis() - isoPlayer0.getLastBump()) / 100L < 15L
                                                        || isoPlayer0.isSprinting()
                                                )
                                                && (isoPlayer1 == null || !isoPlayer1.isNPC());
                                            if (boolean1) {
                                                isoGameCharacter0.bumpNbr++;
                                                int int3 = 10 - isoGameCharacter0.bumpNbr * 3;
                                                int3 += isoGameCharacter0.getPerkLevel(PerkFactory.Perks.Fitness);
                                                int3 += isoGameCharacter0.getPerkLevel(PerkFactory.Perks.Strength);
                                                if (isoGameCharacter0.Traits.Clumsy.isSet()) {
                                                    int3 -= 5;
                                                }

                                                if (isoGameCharacter0.Traits.Graceful.isSet()) {
                                                    int3 += 5;
                                                }

                                                if (isoGameCharacter0.Traits.VeryUnderweight.isSet()) {
                                                    int3 -= 8;
                                                }

                                                if (isoGameCharacter0.Traits.Underweight.isSet()) {
                                                    int3 -= 4;
                                                }

                                                if (isoGameCharacter0.Traits.Obese.isSet()) {
                                                    int3 -= 8;
                                                }

                                                if (isoGameCharacter0.Traits.Overweight.isSet()) {
                                                    int3 -= 4;
                                                }

                                                BodyPart bodyPart = isoGameCharacter0.getBodyDamage().getBodyPart(BodyPartType.Torso_Lower);
                                                if (bodyPart.getAdditionalPain(true) > 20.0F) {
                                                    int3 = (int)((float)int3 - (bodyPart.getAdditionalPain(true) - 20.0F) / 20.0F);
                                                }

                                                int3 = Math.min(80, int3);
                                                int3 = Math.max(1, int3);
                                                if (Rand.Next(int3) == 0 || isoGameCharacter0.isSprinting()) {
                                                    isoGameCharacter0.setVariable("BumpDone", false);
                                                    isoGameCharacter0.setBumpFall(true);
                                                    isoGameCharacter0.setVariable("TripObstacleType", "zombie");
                                                }
                                            } else {
                                                isoGameCharacter0.bumpNbr = 0;
                                            }

                                            isoGameCharacter0.setLastBump(System.currentTimeMillis());
                                            isoGameCharacter0.setBumpedChr(isoGameCharacter1);
                                            isoGameCharacter0.setBumpType(this.getBumpedType(isoGameCharacter1));
                                            boolean boolean2 = isoGameCharacter0.isBehind(isoGameCharacter1);
                                            String string = isoGameCharacter0.getBumpType();
                                            if (boolean2) {
                                                if (string.equals("left")) {
                                                    string = "right";
                                                } else {
                                                    string = "left";
                                                }
                                            }

                                            isoGameCharacter1.setBumpType(string);
                                            isoGameCharacter1.setHitFromBehind(boolean2);
                                            if (boolean1 | GameClient.bClient) {
                                                isoGameCharacter0.actionContext.reportEvent("wasBumped");
                                            }
                                        }

                                        if (GameServer.bServer || this.distToNearestCamCharacter() < 60.0F) {
                                            if (this.isPushedByForSeparate(isoMovingObject1)) {
                                                vector2.setLength((float2 - float1) / 8.0F);
                                                this.nx = this.nx - vector2.x;
                                                this.ny = this.ny - vector2.y;
                                            }

                                            this.collideWith(isoMovingObject1);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    public String getBumpedType(IsoGameCharacter bumped) {
        float float0 = this.x - bumped.x;
        float float1 = this.y - bumped.y;
        String string = "left";
        if (this.dir == IsoDirections.S || this.dir == IsoDirections.SE || this.dir == IsoDirections.SW) {
            if (float0 < 0.0F) {
                string = "left";
            } else {
                string = "right";
            }
        }

        if (this.dir == IsoDirections.N || this.dir == IsoDirections.NE || this.dir == IsoDirections.NW) {
            if (float0 > 0.0F) {
                string = "left";
            } else {
                string = "right";
            }
        }

        if (this.dir == IsoDirections.E) {
            if (float1 > 0.0F) {
                string = "left";
            } else {
                string = "right";
            }
        }

        if (this.dir == IsoDirections.W) {
            if (float1 < 0.0F) {
                string = "left";
            } else {
                string = "right";
            }
        }

        return string;
    }

    private void slideAwayFromWalls() {
        if (this.current != null) {
            IsoZombie isoZombie = Type.tryCastTo(this, IsoZombie.class);
            if (isoZombie != null && (this.isOnFloor() || isoZombie.isKnockedDown())) {
                if (!isoZombie.isCrawling() || isoZombie.getPath2() == null && !isoZombie.isMoving()) {
                    if (!isoZombie.isCurrentState(ClimbOverFenceState.instance()) && !isoZombie.isCurrentState(ClimbThroughWindowState.instance())) {
                        if (isoZombie.hasAnimationPlayer() && isoZombie.getAnimationPlayer().isReady()) {
                            Vector3 vector3 = IsoMovingObject.L_slideAwayFromWalls.vector3;
                            Model.BoneToWorldCoords(isoZombie, isoZombie.getAnimationPlayer().getSkinningBoneIndex("Bip01_Head", -1), vector3);
                            if (Core.bDebug && DebugOptions.instance.CollideWithObstaclesRenderRadius.getValue()) {
                                LineDrawer.DrawIsoCircle(vector3.x, vector3.y, this.z, 0.3F, 16, 1.0F, 1.0F, 0.0F, 1.0F);
                            }

                            Vector2 vector2 = IsoMovingObject.L_slideAwayFromWalls.vector2.set(vector3.x - this.x, vector3.y - this.y);
                            vector2.normalize();
                            vector3.x = vector3.x + vector2.x * 0.3F;
                            vector3.y = vector3.y + vector2.y * 0.3F;
                            if (isoZombie.isKnockedDown()
                                && (isoZombie.isCurrentState(ZombieFallDownState.instance()) || isoZombie.isCurrentState(StaggerBackState.instance()))) {
                                Vector2f vector2f = PolygonalMap2.instance
                                    .resolveCollision(isoZombie, vector3.x, vector3.y, IsoMovingObject.L_slideAwayFromWalls.vector2f);
                                if (vector2f.x != vector3.x || vector2f.y != vector3.y) {
                                    float float0 = zombie.GameTime.getInstance().getMultiplier() / 5.0F;
                                    this.nx = this.nx + (vector2f.x - vector3.x) * float0;
                                    this.ny = this.ny + (vector2f.y - vector3.y) * float0;
                                    return;
                                }
                            }

                            if ((int)vector3.x != this.current.x || (int)vector3.y != this.current.y) {
                                IsoGridSquare isoGridSquare = this.getCell().getGridSquare((int)vector3.x, (int)vector3.y, (int)this.z);
                                if (isoGridSquare != null) {
                                    if (this.current.testCollideAdjacent(this, isoGridSquare.x - this.current.x, isoGridSquare.y - this.current.y, 0)) {
                                        float float1 = zombie.GameTime.getInstance().getMultiplier() / 5.0F;
                                        if (isoGridSquare.x < this.current.x) {
                                            this.nx = this.nx + ((float)this.current.x - vector3.x) * float1;
                                        } else if (isoGridSquare.x > this.current.x) {
                                            this.nx = this.nx + ((float)isoGridSquare.x - vector3.x) * float1;
                                        }

                                        if (isoGridSquare.y < this.current.y) {
                                            this.ny = this.ny + ((float)this.current.y - vector3.y) * float1;
                                        } else if (isoGridSquare.y > this.current.y) {
                                            this.ny = this.ny + ((float)isoGridSquare.y - vector3.y) * float1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private boolean DoCollide(int int6) {
        IsoGameCharacter isoGameCharacter = Type.tryCastTo(this, IsoGameCharacter.class);
        this.current = this.getCell().getGridSquare((int)this.nx, (int)this.ny, (int)this.z);
        if (this instanceof IsoMolotovCocktail) {
            for (int int0 = (int)this.z; int0 > 0; int0--) {
                for (int int1 = -1; int1 <= 1; int1++) {
                    for (int int2 = -1; int2 <= 1; int2++) {
                        IsoGridSquare isoGridSquare0 = this.getCell().createNewGridSquare((int)this.nx + int2, (int)this.ny + int1, int0, false);
                        if (isoGridSquare0 != null) {
                            isoGridSquare0.RecalcAllWithNeighbours(true);
                        }
                    }
                }
            }
        }

        if (this.current != null) {
            if (!this.current.TreatAsSolidFloor()) {
                this.current = this.getCell().getGridSquare((int)this.nx, (int)this.ny, (int)this.z);
            }

            if (this.current == null) {
                return false;
            }

            this.current = this.getCell().getGridSquare((int)this.nx, (int)this.ny, (int)this.z);
        }

        if (this.current != this.last && this.last != null && this.current != null) {
            if (isoGameCharacter != null
                && isoGameCharacter.getCurrentState() != null
                && isoGameCharacter.getCurrentState()
                    .isIgnoreCollide(isoGameCharacter, this.last.x, this.last.y, this.last.z, this.current.x, this.current.y, this.current.z)) {
                return false;
            }

            if (this == IsoCamera.CamCharacter) {
                IsoWorld.instance.CurrentCell.lightUpdateCount = 10;
            }

            int int3 = this.current.getX() - this.last.getX();
            int int4 = this.current.getY() - this.last.getY();
            int int5 = this.current.getZ() - this.last.getZ();
            boolean _boolean = false;
            if (this.last.testCollideAdjacent(this, int3, int4, int5) || this.current == null) {
                _boolean = true;
            }

            if (_boolean) {
                if (this.last.getX() < this.current.getX()) {
                    this.collidedE = true;
                }

                if (this.last.getX() > this.current.getX()) {
                    this.collidedW = true;
                }

                if (this.last.getY() < this.current.getY()) {
                    this.collidedS = true;
                }

                if (this.last.getY() > this.current.getY()) {
                    this.collidedN = true;
                }

                this.current = this.last;
                this.checkBreakHoppable();
                this.checkHitHoppable();
                if (int6 == 2) {
                    if ((this.collidedS || this.collidedN) && (this.collidedE || this.collidedW)) {
                        this.collidedS = false;
                        this.collidedN = false;
                    }
                } else if (int6 == 1 && (this.collidedS || this.collidedN) && (this.collidedE || this.collidedW)) {
                    this.collidedW = false;
                    this.collidedE = false;
                }

                this.Collided();
                return true;
            }
        } else if (this.nx != this.lx || this.ny != this.ly) {
            if (this instanceof IsoZombie && Core.GameMode.equals("Tutorial")) {
                return true;
            }

            if (this.current == null) {
                if (this.nx < this.lx) {
                    this.collidedW = true;
                }

                if (this.nx > this.lx) {
                    this.collidedE = true;
                }

                if (this.ny < this.ly) {
                    this.collidedN = true;
                }

                if (this.ny > this.ly) {
                    this.collidedS = true;
                }

                this.nx = this.lx;
                this.ny = this.ly;
                this.current = this.last;
                this.Collided();
                return true;
            }

            if (isoGameCharacter != null && isoGameCharacter.getPath2() != null) {
                PathFindBehavior2 pathFindBehavior2 = isoGameCharacter.getPathFindBehavior2();
                if ((int)pathFindBehavior2.getTargetX() == (int)this.x
                    && (int)pathFindBehavior2.getTargetY() == (int)this.y
                    && (int)pathFindBehavior2.getTargetZ() == (int)this.z) {
                    return false;
                }
            }

            IsoGridSquare isoGridSquare1 = this.getFeelerTile(this.feelersize);
            if (isoGameCharacter != null) {
                if (isoGameCharacter.isClimbing()) {
                    isoGridSquare1 = this.current;
                }

                if (isoGridSquare1 != null
                    && isoGridSquare1 != this.current
                    && isoGameCharacter.getPath2() != null
                    && !isoGameCharacter.getPath2().crossesSquare(isoGridSquare1.x, isoGridSquare1.y, isoGridSquare1.z)) {
                    isoGridSquare1 = this.current;
                }
            }

            if (isoGridSquare1 != null && isoGridSquare1 != this.current && this.current != null) {
                if (isoGameCharacter != null
                    && isoGameCharacter.getCurrentState() != null
                    && isoGameCharacter.getCurrentState()
                        .isIgnoreCollide(isoGameCharacter, this.current.x, this.current.y, this.current.z, isoGridSquare1.x, isoGridSquare1.y, isoGridSquare1.z)
                    )
                 {
                    return false;
                }

                if (this.current
                    .testCollideAdjacent(
                        this,
                        isoGridSquare1.getX() - this.current.getX(),
                        isoGridSquare1.getY() - this.current.getY(),
                        isoGridSquare1.getZ() - this.current.getZ()
                    )) {
                    if (this.last != null) {
                        if (this.current.getX() < isoGridSquare1.getX()) {
                            this.collidedE = true;
                        }

                        if (this.current.getX() > isoGridSquare1.getX()) {
                            this.collidedW = true;
                        }

                        if (this.current.getY() < isoGridSquare1.getY()) {
                            this.collidedS = true;
                        }

                        if (this.current.getY() > isoGridSquare1.getY()) {
                            this.collidedN = true;
                        }

                        this.checkBreakHoppable();
                        this.checkHitHoppable();
                        if (int6 == 2 && (this.collidedS || this.collidedN) && (this.collidedE || this.collidedW)) {
                            this.collidedS = false;
                            this.collidedN = false;
                        }

                        if (int6 == 1 && (this.collidedS || this.collidedN) && (this.collidedE || this.collidedW)) {
                            this.collidedW = false;
                            this.collidedE = false;
                        }
                    }

                    this.Collided();
                    return true;
                }
            }
        }

        return false;
    }

    private void checkHitHoppable() {
        IsoZombie isoZombie = Type.tryCastTo(this, IsoZombie.class);
        if (isoZombie != null && !isoZombie.bCrawling) {
            if (!isoZombie.isCurrentState(AttackState.instance())
                && !isoZombie.isCurrentState(StaggerBackState.instance())
                && !isoZombie.isCurrentState(ClimbOverFenceState.instance())
                && !isoZombie.isCurrentState(ClimbThroughWindowState.instance())) {
                if (this.collidedW && !this.collidedN && !this.collidedS && this.last.Is(IsoFlagType.HoppableW)) {
                    isoZombie.climbOverFence(IsoDirections.W);
                }

                if (this.collidedN && !this.collidedE && !this.collidedW && this.last.Is(IsoFlagType.HoppableN)) {
                    isoZombie.climbOverFence(IsoDirections.N);
                }

                if (this.collidedS && !this.collidedE && !this.collidedW) {
                    IsoGridSquare isoGridSquare0 = this.last.nav[IsoDirections.S.index()];
                    if (isoGridSquare0 != null && isoGridSquare0.Is(IsoFlagType.HoppableN)) {
                        isoZombie.climbOverFence(IsoDirections.S);
                    }
                }

                if (this.collidedE && !this.collidedN && !this.collidedS) {
                    IsoGridSquare isoGridSquare1 = this.last.nav[IsoDirections.E.index()];
                    if (isoGridSquare1 != null && isoGridSquare1.Is(IsoFlagType.HoppableW)) {
                        isoZombie.climbOverFence(IsoDirections.E);
                    }
                }
            }
        }
    }

    private void checkBreakHoppable() {
        IsoZombie isoZombie = Type.tryCastTo(this, IsoZombie.class);
        if (isoZombie != null && isoZombie.bCrawling) {
            if (!isoZombie.isCurrentState(AttackState.instance())
                && !isoZombie.isCurrentState(StaggerBackState.instance())
                && !isoZombie.isCurrentState(CrawlingZombieTurnState.instance())) {
                IsoDirections isoDirections = IsoDirections.Max;
                if (this.collidedW && !this.collidedN && !this.collidedS) {
                    isoDirections = IsoDirections.W;
                }

                if (this.collidedN && !this.collidedE && !this.collidedW) {
                    isoDirections = IsoDirections.N;
                }

                if (this.collidedS && !this.collidedE && !this.collidedW) {
                    isoDirections = IsoDirections.S;
                }

                if (this.collidedE && !this.collidedN && !this.collidedS) {
                    isoDirections = IsoDirections.E;
                }

                if (isoDirections != IsoDirections.Max) {
                    IsoObject isoObject = this.last.getHoppableTo(this.last.getAdjacentSquare(isoDirections));
                    IsoThumpable isoThumpable = Type.tryCastTo(isoObject, IsoThumpable.class);
                    if (isoThumpable != null && !isoThumpable.isThumpable()) {
                        isoZombie.setThumpTarget(isoThumpable);
                    } else if (isoObject != null && isoObject.getThumpableFor(isoZombie) != null) {
                        isoZombie.setThumpTarget(isoObject);
                    }
                }
            }
        }
    }

    private void checkHitWall() {
        if (this.collidedN || this.collidedS || this.collidedE || this.collidedW) {
            if (this.current != null) {
                IsoPlayer isoPlayer = Type.tryCastTo(this, IsoPlayer.class);
                if (isoPlayer != null) {
                    if (StringUtils.isNullOrEmpty(this.getCollideType())) {
                        boolean _boolean = false;
                        int _int = this.current.getWallType();
                        if ((_int & 1) != 0 && this.collidedN && this.getDir() == IsoDirections.N) {
                            _boolean = true;
                        }

                        if ((_int & 2) != 0 && this.collidedS && this.getDir() == IsoDirections.S) {
                            _boolean = true;
                        }

                        if ((_int & 4) != 0 && this.collidedW && this.getDir() == IsoDirections.W) {
                            _boolean = true;
                        }

                        if ((_int & 8) != 0 && this.collidedE && this.getDir() == IsoDirections.E) {
                            _boolean = true;
                        }

                        if (this.checkVaultOver()) {
                            _boolean = false;
                        }

                        if (_boolean && isoPlayer.isSprinting() && isoPlayer.isLocalPlayer()) {
                            this.setCollideType("wall");
                            isoPlayer.getActionContext().reportEvent("collideWithWall");
                            this.lastCollideTime = 70.0F;
                        }
                    }
                }
            }
        }
    }

    private boolean checkVaultOver() {
        IsoPlayer isoPlayer = (IsoPlayer)this;
        if (isoPlayer.isCurrentState(ClimbOverFenceState.instance()) || isoPlayer.isIgnoreAutoVault()) {
            return false;
        } else if (!isoPlayer.IsRunning() && !isoPlayer.isSprinting() && isoPlayer.isLocalPlayer()) {
            return false;
        } else {
            IsoDirections isoDirections = this.getDir();
            IsoGridSquare isoGridSquare0 = this.current.getAdjacentSquare(IsoDirections.SE);
            if (isoDirections == IsoDirections.SE
                && isoGridSquare0 != null
                && isoGridSquare0.Is(IsoFlagType.HoppableN)
                && isoGridSquare0.Is(IsoFlagType.HoppableW)) {
                return false;
            } else {
                IsoGridSquare isoGridSquare1 = this.current;
                if (this.collidedS) {
                    isoGridSquare1 = this.current.getAdjacentSquare(IsoDirections.S);
                } else if (this.collidedE) {
                    isoGridSquare1 = this.current.getAdjacentSquare(IsoDirections.E);
                }

                if (isoGridSquare1 == null) {
                    return false;
                } else {
                    boolean _boolean = false;
                    if (this.current.getProperties().Is(IsoFlagType.HoppableN)
                        && this.collidedN
                        && !this.collidedW
                        && !this.collidedE
                        && (isoDirections == IsoDirections.NW || isoDirections == IsoDirections.N || isoDirections == IsoDirections.NE)) {
                        isoDirections = IsoDirections.N;
                        _boolean = true;
                    }

                    if (isoGridSquare1.getProperties().Is(IsoFlagType.HoppableN)
                        && this.collidedS
                        && !this.collidedW
                        && !this.collidedE
                        && (isoDirections == IsoDirections.SW || isoDirections == IsoDirections.S || isoDirections == IsoDirections.SE)) {
                        isoDirections = IsoDirections.S;
                        _boolean = true;
                    }

                    if (this.current.getProperties().Is(IsoFlagType.HoppableW)
                        && this.collidedW
                        && !this.collidedN
                        && !this.collidedS
                        && (isoDirections == IsoDirections.NW || isoDirections == IsoDirections.W || isoDirections == IsoDirections.SW)) {
                        isoDirections = IsoDirections.W;
                        _boolean = true;
                    }

                    if (isoGridSquare1.getProperties().Is(IsoFlagType.HoppableW)
                        && this.collidedE
                        && !this.collidedN
                        && !this.collidedS
                        && (isoDirections == IsoDirections.NE || isoDirections == IsoDirections.E || isoDirections == IsoDirections.SE)) {
                        isoDirections = IsoDirections.E;
                        _boolean = true;
                    }

                    if (_boolean && isoPlayer.isSafeToClimbOver(isoDirections)) {
                        ClimbOverFenceState.instance().setParams(isoPlayer, isoDirections);
                        isoPlayer.getActionContext().reportEvent("EventClimbFence");
                        return true;
                    } else {
                        return false;
                    }
                }
            }
        }
    }

    public void setMovingSquareNow() {
        if (this.movingSq != null) {
            this.movingSq.getMovingObjects().remove(this);
            this.movingSq = null;
        }

        if (this.current != null && !this.current.getMovingObjects().contains(this)) {
            this.current.getMovingObjects().add(this);
            this.movingSq = this.current;
        }
    }

    public IsoGridSquare getFeelerTile(float dist) {
        Vector2 vector2 = tempo;
        vector2.x = this.nx - this.lx;
        vector2.y = this.ny - this.ly;
        vector2.setLength(dist);
        return this.getCell().getGridSquare((int)(this.x + vector2.x), (int)(this.y + vector2.y), (int)this.z);
    }

    public void DoCollideNorS() {
        this.ny = this.ly;
    }

    public void DoCollideWorE() {
        this.nx = this.lx;
    }

    public int getTimeSinceZombieAttack() {
        return this.TimeSinceZombieAttack;
    }

    public void setTimeSinceZombieAttack(int _TimeSinceZombieAttack) {
        this.TimeSinceZombieAttack = _TimeSinceZombieAttack;
    }

    public boolean isCollidedE() {
        return this.collidedE;
    }

    public void setCollidedE(boolean _collidedE) {
        this.collidedE = _collidedE;
    }

    public boolean isCollidedN() {
        return this.collidedN;
    }

    public void setCollidedN(boolean _collidedN) {
        this.collidedN = _collidedN;
    }

    public IsoObject getCollidedObject() {
        return this.CollidedObject;
    }

    public void setCollidedObject(IsoObject _CollidedObject) {
        this.CollidedObject = _CollidedObject;
    }

    public boolean isCollidedS() {
        return this.collidedS;
    }

    public void setCollidedS(boolean _collidedS) {
        this.collidedS = _collidedS;
    }

    public boolean isCollidedThisFrame() {
        return this.collidedThisFrame;
    }

    public void setCollidedThisFrame(boolean _collidedThisFrame) {
        this.collidedThisFrame = _collidedThisFrame;
    }

    public boolean isCollidedW() {
        return this.collidedW;
    }

    public void setCollidedW(boolean _collidedW) {
        this.collidedW = _collidedW;
    }

    public boolean isCollidedWithDoor() {
        return this.CollidedWithDoor;
    }

    public void setCollidedWithDoor(boolean _CollidedWithDoor) {
        this.CollidedWithDoor = _CollidedWithDoor;
    }

    public boolean isCollidedWithVehicle() {
        return this.collidedWithVehicle;
    }

    public IsoGridSquare getCurrentSquare() {
        return this.current;
    }

    public IsoMetaGrid.Zone getCurrentZone() {
        return this.current != null ? this.current.getZone() : null;
    }

    public void setCurrent(IsoGridSquare _current) {
        this.current = _current;
    }

    @Override
    public boolean isDestroyed() {
        return this.destroyed;
    }

    public void setDestroyed(boolean _destroyed) {
        this.destroyed = _destroyed;
    }

    public boolean isFirstUpdate() {
        return this.firstUpdate;
    }

    public void setFirstUpdate(boolean _firstUpdate) {
        this.firstUpdate = _firstUpdate;
    }

    public Vector2 getHitDir() {
        return this.hitDir;
    }

    public void setHitDir(Vector2 _hitDir) {
        this.hitDir.set(_hitDir);
    }

    public float getImpulsex() {
        return this.impulsex;
    }

    public void setImpulsex(float _impulsex) {
        this.impulsex = _impulsex;
    }

    public float getImpulsey() {
        return this.impulsey;
    }

    public void setImpulsey(float _impulsey) {
        this.impulsey = _impulsey;
    }

    public float getLimpulsex() {
        return this.limpulsex;
    }

    public void setLimpulsex(float _limpulsex) {
        this.limpulsex = _limpulsex;
    }

    public float getLimpulsey() {
        return this.limpulsey;
    }

    public void setLimpulsey(float _limpulsey) {
        this.limpulsey = _limpulsey;
    }

    public float getHitForce() {
        return this.hitForce;
    }

    public void setHitForce(float _hitForce) {
        this.hitForce = _hitForce;
    }

    public float getHitFromAngle() {
        return this.hitFromAngle;
    }

    public void setHitFromAngle(float _hitFromAngle) {
        this.hitFromAngle = _hitFromAngle;
    }

    public IsoGridSquare getLastSquare() {
        return this.last;
    }

    public void setLast(IsoGridSquare _last) {
        this.last = _last;
    }

    public float getLx() {
        return this.lx;
    }

    public void setLx(float _lx) {
        this.lx = _lx;
    }

    public float getLy() {
        return this.ly;
    }

    public void setLy(float _ly) {
        this.ly = _ly;
    }

    public float getLz() {
        return this.lz;
    }

    public void setLz(float _lz) {
        this.lz = _lz;
    }

    public float getNx() {
        return this.nx;
    }

    public void setNx(float _nx) {
        this.nx = _nx;
    }

    public float getNy() {
        return this.ny;
    }

    public void setNy(float _ny) {
        this.ny = _ny;
    }

    public boolean getNoDamage() {
        return this.noDamage;
    }

    public void setNoDamage(boolean dmg) {
        this.noDamage = dmg;
    }

    public boolean isSolid() {
        return this.solid;
    }

    public void setSolid(boolean _solid) {
        this.solid = _solid;
    }

    public float getStateEventDelayTimer() {
        return this.StateEventDelayTimer;
    }

    public void setStateEventDelayTimer(float _StateEventDelayTimer) {
        this.StateEventDelayTimer = _StateEventDelayTimer;
    }

    public float getWidth() {
        return this.width;
    }

    public void setWidth(float _width) {
        this.width = _width;
    }

    public boolean isbAltCollide() {
        return this.bAltCollide;
    }

    public void setbAltCollide(boolean _bAltCollide) {
        this.bAltCollide = _bAltCollide;
    }

    public boolean isShootable() {
        return this.shootable;
    }

    public void setShootable(boolean _shootable) {
        this.shootable = _shootable;
    }

    public IsoZombie getLastTargettedBy() {
        return this.lastTargettedBy;
    }

    public void setLastTargettedBy(IsoZombie _lastTargettedBy) {
        this.lastTargettedBy = _lastTargettedBy;
    }

    public boolean isCollidable() {
        return this.Collidable;
    }

    public void setCollidable(boolean _Collidable) {
        this.Collidable = _Collidable;
    }

    public float getScriptnx() {
        return this.scriptnx;
    }

    public void setScriptnx(float _scriptnx) {
        this.scriptnx = _scriptnx;
    }

    public float getScriptny() {
        return this.scriptny;
    }

    public void setScriptny(float _scriptny) {
        this.scriptny = _scriptny;
    }

    public String getScriptModule() {
        return this.ScriptModule;
    }

    public void setScriptModule(String _ScriptModule) {
        this.ScriptModule = _ScriptModule;
    }

    public Vector2 getMovementLastFrame() {
        return this.movementLastFrame;
    }

    public void setMovementLastFrame(Vector2 _movementLastFrame) {
        this.movementLastFrame = _movementLastFrame;
    }

    public float getFeelersize() {
        return this.feelersize;
    }

    public void setFeelersize(float _feelersize) {
        this.feelersize = _feelersize;
    }

    public byte canHaveMultipleHits() {
        byte _byte = 0;
        ArrayList arrayList = IsoWorld.instance.CurrentCell.getObjectList();

        for (int _int = 0; _int < arrayList.size(); _int++) {
            IsoMovingObject isoMovingObject0 = (IsoMovingObject)arrayList.get(_int);
            IsoPlayer isoPlayer = Type.tryCastTo(isoMovingObject0, IsoPlayer.class);
            if (isoPlayer != null) {
                HandWeapon handWeapon = Type.tryCastTo(isoPlayer.getPrimaryHandItem(), HandWeapon.class);
                if (handWeapon == null || isoPlayer.bDoShove || isoPlayer.isForceShove()) {
                    handWeapon = isoPlayer.bareHands;
                }

                float float0 = IsoUtils.DistanceTo(isoPlayer.x, isoPlayer.y, this.x, this.y);
                float float1 = handWeapon.getMaxRange() * handWeapon.getRangeMod(isoPlayer) + 2.0F;
                if (!(float0 > float1)) {
                    float float2 = isoPlayer.getDotWithForwardDirection(this.x, this.y);
                    if (!((double)float0 > 2.5) || !(float2 < 0.1F)) {
                        LosUtil.TestResults testResults = LosUtil.lineClear(
                            isoPlayer.getCell(),
                            (int)isoPlayer.getX(),
                            (int)isoPlayer.getY(),
                            (int)isoPlayer.getZ(),
                            (int)this.getX(),
                            (int)this.getY(),
                            (int)this.getZ(),
                            false
                        );
                        if (testResults != LosUtil.TestResults.Blocked && testResults != LosUtil.TestResults.ClearThroughClosedDoor) {
                            if (++_byte >= 2) {
                                return _byte;
                            }
                        }
                    }
                }
            }
        }

        return _byte;
    }

    public boolean isOnFloor() {
        return this.bOnFloor;
    }

    public void setOnFloor(boolean _bOnFloor) {
        this.bOnFloor = _bOnFloor;
    }

    public void Despawn() {
    }

    public boolean isCloseKilled() {
        return this.closeKilled;
    }

    public void setCloseKilled(boolean _closeKilled) {
        this.closeKilled = _closeKilled;
    }

    @Override
    public Vector2 getFacingPosition(Vector2 pos) {
        pos.set(this.getX(), this.getY());
        return pos;
    }

    private boolean isInLoadedArea(int int2, int int1) {
        if (GameServer.bServer) {
            for (int int0 = 0; int0 < ServerMap.instance.LoadedCells.size(); int0++) {
                ServerMap.ServerCell serverCell = (ServerMap.ServerCell)ServerMap.instance.LoadedCells.get(int0);
                if (int2 >= serverCell.WX * 50 && int2 < (serverCell.WX + 1) * 50 && int1 >= serverCell.WY * 50 && int1 < (serverCell.WY + 1) * 50) {
                    return true;
                }
            }
        } else {
            for (int int3 = 0; int3 < IsoPlayer.numPlayers; int3++) {
                IsoChunkMap isoChunkMap = IsoWorld.instance.CurrentCell.ChunkMap[int3];
                if (!isoChunkMap.ignore
                    && int2 >= isoChunkMap.getWorldXMinTiles()
                    && int2 < isoChunkMap.getWorldXMaxTiles()
                    && int1 >= isoChunkMap.getWorldYMinTiles()
                    && int1 < isoChunkMap.getWorldYMaxTiles()) {
                    return true;
                }
            }
        }

        return false;
    }

    public boolean isCollided() {
        return !StringUtils.isNullOrWhitespace(this.getCollideType());
    }

    public String getCollideType() {
        return this.collideType;
    }

    public void setCollideType(String _collideType) {
        this.collideType = _collideType;
    }

    public float getLastCollideTime() {
        return this.lastCollideTime;
    }

    public void setLastCollideTime(float _lastCollideTime) {
        this.lastCollideTime = _lastCollideTime;
    }

    public ArrayList<IsoZombie> getEatingZombies() {
        return this.eatingZombies;
    }

    public void setEatingZombies(ArrayList<IsoZombie> zeds) {
        this.eatingZombies.clear();
        this.eatingZombies.addAll(zeds);
    }

    public boolean isEatingOther(IsoMovingObject other) {
        return other == null ? false : other.eatingZombies.contains(this);
    }

    public float getDistanceSq(IsoMovingObject other) {
        float float0 = this.x - other.x;
        float float1 = this.y - other.y;
        float0 *= float0;
        float1 *= float1;
        return float0 + float1;
    }

    public void setZombiesDontAttack(boolean b) {
        this.zombiesDontAttack = b;
    }

    public boolean isZombiesDontAttack() {
        return this.zombiesDontAttack;
    }

    private static final class L_postUpdate {
        static final Vector2f vector2f = new Vector2f();
    }

    private static final class L_slideAwayFromWalls {
        static final Vector2f vector2f = new Vector2f();
        static final Vector2 vector2 = new Vector2();
        static final Vector3 vector3 = new Vector3();
    }

    public static class TreeSoundManager {
        private ArrayList<IsoGridSquare> squares = new ArrayList();
        private long[] soundTime = new long[6];
        private Comparator<IsoGridSquare> comp = (isoGridSquare0, isoGridSquare1) -> {
            float float0 = this.getClosestListener((float)isoGridSquare0.x + 0.5F, (float)isoGridSquare0.y + 0.5F, (float)isoGridSquare0.z);
            float float1 = this.getClosestListener((float)isoGridSquare1.x + 0.5F, (float)isoGridSquare1.y + 0.5F, (float)isoGridSquare1.z);
            if (float0 > float1) {
                return 1;
            } else {
                return float0 < float1 ? -1 : 0;
            }
        };

        public void addSquare(IsoGridSquare square) {
            if (!this.squares.contains(square)) {
                this.squares.add(square);
            }
        }

        public void update() {
            if (!this.squares.isEmpty()) {
                Collections.sort(this.squares, this.comp);
                long _long = System.currentTimeMillis();

                for (int int0 = 0; int0 < this.soundTime.length && int0 < this.squares.size(); int0++) {
                    IsoGridSquare isoGridSquare = (IsoGridSquare)this.squares.get(int0);
                    if (!(this.getClosestListener((float)isoGridSquare.x + 0.5F, (float)isoGridSquare.y + 0.5F, (float)isoGridSquare.z) > 20.0F)) {
                        int int1 = this.getFreeSoundSlot(_long);
                        if (int1 == -1) {
                            break;
                        }

                        Audio audio = null;
                        float float0 = 0.05F;
                        float float1 = 16.0F;
                        float float2 = 0.29999998F;
                        if (GameClient.bClient) {
                            audio = zombie.SoundManager.instance
                                .PlayWorldSoundImpl(
                                    "Bushes", false, isoGridSquare.getX(), isoGridSquare.getY(), isoGridSquare.getZ(), float0, float1, float2, false
                                );
                        } else {
                            BaseSoundEmitter baseSoundEmitter = IsoWorld.instance
                                .getFreeEmitter((float)isoGridSquare.x + 0.5F, (float)isoGridSquare.y + 0.5F, (float)isoGridSquare.z);
                            if (baseSoundEmitter.playSound("Bushes") != 0L) {
                                this.soundTime[int1] = _long;
                            }
                        }

                        if (audio != null) {
                            this.soundTime[int1] = _long;
                        }
                    }
                }

                this.squares.clear();
            }
        }

        private float getClosestListener(float float5, float float6, float float7) {
            float float0 = Float.MAX_VALUE;

            for (int _int = 0; _int < IsoPlayer.numPlayers; _int++) {
                IsoPlayer isoPlayer = IsoPlayer.players[_int];
                if (isoPlayer != null && isoPlayer.getCurrentSquare() != null) {
                    float float1 = isoPlayer.getX();
                    float float2 = isoPlayer.getY();
                    float float3 = isoPlayer.getZ();
                    float float4 = IsoUtils.DistanceTo(float1, float2, float3 * 3.0F, float5, float6, float7 * 3.0F);
                    if (isoPlayer.Traits.HardOfHearing.isSet()) {
                        float4 *= 4.5F;
                    }

                    if (float4 < float0) {
                        float0 = float4;
                    }
                }
            }

            return float0;
        }

        private int getFreeSoundSlot(long long1) {
            long long0 = Long.MAX_VALUE;
            int int0 = -1;

            for (int int1 = 0; int1 < this.soundTime.length; int1++) {
                if (this.soundTime[int1] < long0) {
                    long0 = this.soundTime[int1];
                    int0 = int1;
                }
            }

            return long1 - long0 < 1000L ? -1 : int0;
        }
    }
}
